package com.example.forum.Controller;

import com.example.forum.common.AppResult;
import com.example.forum.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

/* @Author      zouzh
 * @PackageName forum
 * @Package     com.example.forum.Controller
 * @Date        2023/9/13 20:11
 */
@Api(tags = "测试类的相关接口")
@RestController
@RequestMapping("/test")
public class test {

    @ApiOperation("测试接口1")
    @GetMapping("/t")
    public String test(){
        return "hello";
    }

    @ApiOperation("测试接口2")
    @GetMapping("/exception")
    public AppResult textEcxeption() throws Exception {
        throw new Exception("这是一个Exception");
    }
    @ApiOperation("测试接口3")
    @GetMapping("/appexception")
    public AppResult textApplicationEcxeption() {
        throw new ApplicationException("这是一个appException");
    }

    @ApiOperation("测试接口4，按传入的姓名显示")
    @PostMapping("/hello")
    public String hello(@ApiParam("姓名") @RequestParam("name") String name){
        return "name: " + name;
    }
}
